$execute as @s[tag=!smithingTable.itemSlot] run return run execute as @n[tag=smithingTable.itemSlot,type=item_display,distance=..500] at @s run function vs:system/game_ctrol/smithing_table/slot/take_item {UUID:$(UUID)}

summon armor_stand ~ ~ ~ {Tags:[temp],Invisible:true,Marker:true,Invulnerable:true}
data modify entity @n[tag=temp,distance=..3,type=armor_stand] HandItems[0] set from entity @s item
$item replace entity @p[nbt={UUID:$(UUID)}] weapon.mainhand from entity @n[tag=temp,distance=..3,type=armor_stand] weapon.mainhand
kill @n[tag=temp,distance=..5,type=armor_stand]
function vs:system/game_ctrol/smithing_table/slot/empty

playsound entity.item_frame.remove_item master @a ~ ~ ~ 1.0 1.0
particle minecraft:white_smoke ~ ~0.2 ~ 0.3 0 0.3 0 5